[//I CAN HAS LASSO?


	//$show_admin_content = true;

	// config for sessions
	var: 'authenticationExpiresMinutes' = 320;
	var: 'longtermExpiresMinutes' = 320;
	var: 'cookieExpiresMinutes' = 320;
	(!var_Defined('show_admin_content')) ? var('show_admin_content' = false);
	
	(!var_Defined('navbarout')) ? var('navbarout' = string);
	
	
	
	// authentication is the short-term, user-session
	Session_Start: 
		-Name='Authentication', 
		-UseCookie,
		-Expires=$authenticationExpiresMinutes,
		-Path='/',
		;
		
		
		
		
	
	//	Add variables to sessions
	//	
	//	This adds the variables that most users will be
	//	authenticated and tracked by.
	
	Session_AddVariable: -Name='Authentication', 'user_UID';
	Session_AddVariable: -Name='Authentication', 'user_usertype_Title';
	Session_AddVariable: -Name='Authentication', 'user_Login_Name';
	Session_AddVariable: -Name='Authentication', 'user_Access_Level';
	Session_AddVariable: -Name='Authentication', 'AuthenticationStatus';
	Session_AddVariable: -Name='Authentication', 'apparent_user_usertype_UID';
	Session_AddVariable: -Name='Authentication', 'apparent_user_Access_Level';
	Session_AddVariable: -Name='Authentication', 'apparent_AuthenticationStatus';

	Session_AddVariable: -Name='Authentication', 'navbarout';

	
	
	//	Authentication defaults
	//	
	//	Sets the default user type to `visitor`.
	//	
	//	This way, if we do not know what they are, they do not get
	//	to stuff they ought not.
	(!var_Defined('thisSearch')) ? var('thisSearch' = array);
	(!var_Defined('thisStatement')) ? var('thisStatement' = string);
	(!var_Defined('user_UID')) ? var('user_UID' = 'unknown');
	(!var_Defined('authenticationStatus')) ? var('authenticationStatus' = 'Unauthorized');
	(!var_Defined('expandedRecords')) ? var('expandedRecords' = map('uh'='oh'));
	
	/*
	If: $authenticationStatus == 'Unauthorized';
				$public_content += $authenticationStatus;
				fail(-1, 'Unauth Error');
	else;
				$public_content += $authenticationStatus;
				fail(-1, 'Auth Error');
	/if;
	*/
	
	If: $authenticationStatus == 'Unauthorized';
			// user is NOT logged in
			//user_usertype_Title_UID
			
			//Sets the `user_usertype_Title_UID` variable that tracks the userºs real 
			//information
			If: (Var_Defined: 'user_usertype_UID') == false;
					Var: 'user_usertype_UID' = 'visitor';
			/If;
			
			//	user_usertype_Title information
			//	
			//	Grabs and sets the access level for the user
			
			var: 'statement'  = 'SELECT * FROM ' $siteDB '.usertypes AS ut WHERE ut.UID = "' $user_usertype_UID '" LIMIT 1';
			Inline: 
				$connection_db,
				-SQL=$statement,
				;

					if(error_msg != 'No error');
							$public_content = 'Oops! The server made a boo boo!';
							$public_content += Error_Msg;
							'<br />';
							//$statement;
							//'<br />';
							//$connection_db;
					/if;
					If: (Found_Count) == 1;
							rows;
									Var: 'user_Access_Level'    =  integer(column('Access_Level'));
									Var: 'user_usertype_Title'          =  column('Title');
							/rows;
					Else;
					
							// need a better warning system built here
					
							If: Error_Msg != 'No error';
									Error_Msg;
							/If;
							Error_SetErrorMessage: 'Error - User
							There has been an error in the authentication system of this website.';
							Error_SetErrorCode: 22001;
							If: Error_Msg != 'No error';
									@Error_Msg;
									Abort;
							/If;
							Var: 'user_Access_Level'    =  100;
							Var: 'user_usertype_Title'      =  'Visitor';
					/If;
			/Inline;

			
			
			
			
			//	Authetication information
			//	
			//	Here is the variabes that the authentication system reads.
			//	
			//	This is the information that the spoofing system presents to
			//	the pageprotection routines.
			
			Var: 'apparent_AuthenticationStatus' =  $authenticationStatus;
			Var: 'apparent_user_Access_Level'      =  $user_Access_Level;
			Var: 'apparent_user_usertype_Title'    =  $user_usertype_Title;
			Var: 'apparent_user_usertype_UID'          =  $user_usertype_UID;
	Else;
			// nothing, for now...
	/If;
	
	
	
	
	
		//SuperUser and Admin stuff 
	
	If: $user_Access_Level <= 2;
			Session_AddVariable: -Name='Authentication', 'show_admin_content';
			Session_AddVariable: -Name='Authentication', 'spoof_user_usertype_UID';
			Session_AddVariable: -Name='Authentication', 'spoof_user_Access_Level';
			Session_AddVariable: -Name='Authentication', 'spoof_AuthenticationStatus';
			Session_AddVariable: -Name='Authentication', 'spoof_user_usertype_Title';
			Define: -Name='spoof_user_usertype_UID', -Default=$apparent_user_usertype_UID;
			Define: -Name='spoof_user_Access_Level', -Default=$apparent_user_Access_Level;
			Define: -Name='spoof_AuthenticationStatus', -Default=$apparent_AuthenticationStatus;
			Define: -Name='spoof_user_usertype_Title', -Default=$user_usertype_Title;	
			//Define: -Name='show_admin_content', -Default=true;
			Var: 'show_admin_content'               =  true;
			Var: 'apparent_user_usertype_UID'       =  $spoof_user_usertype_UID;
			Var: 'apparent_user_Access_Level'       =  $spoof_user_Access_Level;
			Var: 'apparent_AuthenticationStatus'    =  $spoof_AuthenticationStatus;
			Var: 'apparent_user_usertype_Title'     =  $spoof_user_usertype_Title;
	/If;
	If: !(var_defined:'pagesTimeOut') || $pagesTimeOut == true;
			If: $apparent_AuthenticationStatus == 'Authorized';
					Var:
						'redirectPage'              =  true,
						'refreshLandingPage'        =  '/_Auth/_TimeOut/',
						'refreshLandingParameters'  =  '?go=' (response_path),
						;
			Else;
					Var: 'redirectPage'            =  false;
			/If;
	/If;



]